package com.z.springkotlinz.controller

import com.z.springkotlinz.domain.User
import com.z.springkotlinz.service.IUserService
import org.springframework.http.ResponseEntity
import org.springframework.web.bind.annotation.*

@RestController
@RequestMapping("user")
class UserController(
        val userService: IUserService
) {

    @PostMapping
    fun save (@RequestBody user: User):ResponseEntity<Unit>{
       return userService.save(user)
    }

    @PutMapping
    fun update (@RequestBody user: User):ResponseEntity<Unit>{
        return userService.update(user)
    }
    @GetMapping
    fun list (@RequestParam id :Long):ResponseEntity<User>{
        return userService.list(id)
    }
    @DeleteMapping
    fun delete (@RequestParam id :Long):ResponseEntity<Unit>{
        return userService.delete(id)
    }
}